<?php
/**************************************************************************************************
|
| AudioShare - Audio Sharing Script
| http://www.audiosharescript.com
| webmaster@audiosharescript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.audiosharescript.com/eula.html and to be bound by it.
|
| Copyright (c) 2010 AudioShareScript.com. All rights reserved.
|**************************************************************************************************/

include("include/config.php");
include("include/functions/import.php");
$thebaseurl = $config['baseurl'];

if ($_SESSION[USERID] != "" && $_SESSION[USERID] >= 0 && is_numeric($_SESSION[USERID]))
{
	$messageid = intval($_REQUEST[messageid]);
	if (is_numeric($messageid) && $messageid>0)
	{
		$query = "SELECT MSGTO from messages_inbox where MID='".mysql_real_escape_string($messageid)."' order by MID desc limit 1";
		$executequery = $conn->Execute($query);
		$MSGTO = $executequery->fields[MSGTO];

		if (is_numeric($MSGTO) && $MSGTO != "" && $MSGTO == $_SESSION[USERID])
		{
			$query = "DELETE FROM messages_inbox where MID='".mysql_real_escape_string($messageid)."' limit 1";
			$conn->Execute($query);
			
			if(mysql_affected_rows()==1)
			{
				$error = "1";
			}
			else
			{
				$error = "0";
			}
		}
		else
		{
			$error = "0";
		}
	
	}
	else
	{
		$error = "0";
	}
	header("Location:$config[baseurl]/myinbox.php?deleted=$error");
}
else
{
	header("Location:$config[baseurl]/login.php");exit;
}

?>